#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 405;
int n, m, a[N], f[2][N][N];

struct Node {
  int s, t, c;
  Node(int _s, int _t, int _c) : s(_s), t(_t), c(_c) {}
};
std::vector<Node> vec[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("CppTest.in", "r", stdin);
  freopen("CppTest.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1, s, t, c, r; i <= m; ++i) {
    scanf("%d%d%d%d", &s, &t, &c, &r);
    vec[std::min(r + 1, t - s)].push_back(Node(s, t, c));
  }
  memset(f, 0x3f, sizeof(f));
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) f[0][i][j] = a[j] - a[i];
  for (int k = 1; k < n; ++k) {
    bool sta = !(k & 1);
    for (std::vector<Node>::iterator i = vec[k].begin(); i != vec[k].end(); ++i)
      ans = std::max(ans, 1ll * f[sta][i->s][i->t] * (i->c));
    for (int l = 1; l <= n; ++l) {
      f[!sta][l][l] = 0;
      for (int r = l + 1, h = l; r <= n; ++r) {
        while (f[sta][l][h] < a[r] - a[h]) ++h;
        f[!sta][l][r] = std::min(f[sta][l][h], a[r] - a[h - 1]);
      }
    }
  }
  printf("%lld", ans);
  return 0;
}